package cn.stylefeng.guns.modular.yingbao.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.modular.yingbao.entity.UserIndent;
import cn.stylefeng.guns.modular.yingbao.model.params.UserIndentParam;
import cn.stylefeng.guns.modular.yingbao.service.UserIndentService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * 用户付款表控制器
 *
 * @author zs
 * @Date 2019-12-16 17:01:53
 */
@Api(tags = "用户付款模块")
@CrossOrigin
@Controller
@RequestMapping("/userIndent")
public class UserIndentController extends BaseController {

    private String PREFIX = "/userIndent";

    @Autowired
    private UserIndentService userIndentService;

    /**
     * 跳转到主页面
     *
     * @author zs
     * @Date 2019-12-16
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/userIndent.html";
    }

    /**
     * 新增页面
     *
     * @author zs
     * @Date 2019-12-16
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/userIndent_add.html";
    }

    /**
     * 编辑页面
     *
     * @author zs
     * @Date 2019-12-16
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/userIndent_edit.html";
    }

    /**
     * 新增接口
     *
     * @author zs
     * @Date 2019-12-16
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(UserIndentParam userIndentParam) {
        this.userIndentService.add(userIndentParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author zs
     * @Date 2019-12-16
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(UserIndentParam userIndentParam) {
        this.userIndentService.update(userIndentParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author zs
     * @Date 2019-12-16
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(UserIndentParam userIndentParam) {
        this.userIndentService.delete(userIndentParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author zs
     * @Date 2019-12-16
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(UserIndentParam userIndentParam) {
        UserIndent detail = this.userIndentService.getById(userIndentParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author zs
     * @Date 2019-12-16
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(UserIndentParam userIndentParam) {
        return this.userIndentService.findPageBySpec(userIndentParam);
    }

    @PostMapping("addIndent")
    @ResponseBody
    @ApiOperation("添加用户订单")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "myuserid",value = "用户id"),
            @ApiImplicitParam(name = "pic",value = "转账凭证"),
            @ApiImplicitParam(name = "payeeid",value = "平台收账id"),
            @ApiImplicitParam(name = "backup1",value = "会员账号"),
            @ApiImplicitParam(name = "backup3",value = "开通那种会员的id"),
    })
    public ResponseData addIndent(String myuserid,String pic,int payeeid,int backup1,int backup3){
        return userIndentService.addIndent(myuserid,pic,payeeid,backup1,backup3);
    }

    @PostMapping("queryAll")
    @ResponseBody
    @ApiOperation("查看所有开通会员的记录")
    @ApiImplicitParam(name = "status",value = "3,都有.0,未审核的记录.1,同意的记录.2,审核未通过")
    public ResponseData queryAll(String status){
        return userIndentService.queryAll(status);
    }

    @PostMapping("upStatus")
    @ResponseBody
    @ApiOperation("修改开通会员状态")
    @ApiImplicitParam(name = "id",value = "主键id")
    public ResponseData upStatus(String id,String status){
        return userIndentService.upStatus(id,status);
    }



}


